FROM php:8.2-fpm-alpine AS php

RUN apk add --no-cache git zip unzip icu-dev nginx \
    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && rm -f /var/cache/apk/*

# 配置并安装 intl 扩展
RUN docker-php-ext-configure intl && \
    docker-php-ext-install intl 

WORKDIR /var/www/html

# 将当前目录下所有文件拷贝到/app
COPY . /var/www/html/

RUN composer install --no-interaction --optimize-autoloader

# 设置文件权限
RUN chown -R www-data:www-data /var/www/html \
    && chmod -R 777 /var/www/html/writable

# 复制自定义的 Nginx 配置文件到容器
COPY conf/nginx.conf /etc/nginx/http.d/default.conf

# 暴露端口
EXPOSE 80

# 设置启动命令
CMD ["sh", "-c", "php-fpm -D && nginx -g 'daemon off;'"]